home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-12-03 | 5.9 KB | 144 lines | [TEXT/MPS ] |
- # UserStartup•ToolServer
- #
- # Copyright Apple Computer, Inc. 1991
- # All Rights Reserved.
- #
- # by Peter Canning and Brian Strull
- # (with lots of help from Mitch Adler)
- #
-
- # This file defines some menu items and aliases for making ToolServer easier
- # to use from the MPW Shell. This is a startup file for the MPW Shell, and
- # should be moved to either your MPW directory or into the MPW preferences
- # folder. This file is not required for running ToolServer, but illustrates
- # some techniques for using ToolServer from the MPW Shell.
-
- # This file sets up and defines an alias ToolServerExecute for sending
- # commands to a ToolServer in a very similar way to how commands are sent
- # to MPW Shell.
-
- # ToolServerExecute needs MPW Shell version 3.3a8 or later, and ToolServer
- # version 1.0a4 or later.
-
- # ToolServerExecute works similarly to pressing the ENTER key, but sends the
- # commands to a ToolServer process running on some machine on the network.
- #
- # If the selection is empty, the entire line containing the selection is
- # sent to ToolServer and a newline is appended to the end of the line,
- # otherwise (if the selection is non-empty), the selection is sent to
- # ToolServer. In both cases the text is evaluated by ToolServer not
- # by MPW Shell. This means that the ToolServer default directory, aliases,
- # variable settings (especially "{Commands}") will affect the behaviour of
- # the evaluation.
- #
- # The disposition of the results (standard output, and standard error) of the
- # commands sent to ToolServer are controlled by a number of factors.
- # First, the rules of rshell and ToolServer are followed (see the
- # ToolServer documentation about redirection). By default, script output from
- # ToolServer will be returned to the MPW Shell where it will be processed by
- # ToolServerExecute as specified by the MPW Shell variable ToolServerRedirection.
- # If ToolServerRedirection is not set, the output will be appended to the end
- # of the {Active} window (this, unfortunately, is slightly different than what
- # happens when you press the ENTER key in MPW Shell). You are advised to redirect
- # ToolServer output into another window, so that the MPW Shell and ToolServer
- # output does not get mixed up (and so you don't get mixed up either).
-
- # The following variables can be used to configure the behavior of
- # ToolServerExecute:
-
- # The variable WhichToolServer controls what process to send commands to.
- # It should be set to one of the options that controls rshell:
- # -b background (ToolServer on the local machine)
- # -f foreground (MPW Shell on the local machine)
- # -r Zone:Machine:Application some other ToolServer or MPW Shell
- #
- # If the variable is not set, the PPC browser is used.
-
- Set WhichToolServer '-b' # ToolServer on local machine
- export WhichToolServer
-
- # The variable ToolServerRedirection controls the disposition of output
- # from ToolServer. We suggest directing standard output and diagnostic
- # output to another window.
-
- set ToolServerWindow "{MPW}WorkSheet•TS"
- set ToolServerRedirection "∑∑ ∂'{ToolServerWindow}∂'" # Append output (and error) to the end of "{MPW}WorkSheet•TS"
- export ToolServerRedirection
-
- # Create a ToolServer menu.
- #
- # YOU MUST CONNECT ToolServerExecute TO A MENU ENTRY OR KEY.
- # Since it acts on the selection in the {Active} window, you can't
- # type it as an MPW Shell command and press ENTER.
- #
- # The following binds ToolServerExecute to Command-\ (Command-Backslash).
-
- addmenu ToolServer 'Execute Selection/\' ToolServerExecute
-
- # Set Environment will copy your shell variables, aliases, exports, and
- # current directory from the MPW Shell to ToolServer. You can use this
- # menu item for synchronizing your environment.
-
- addmenu ToolServer 'Set Environment' 'UpdateToolServerEnv'
-
- # Open Output opens a window in the MPW Shell on the file containing your
- # ToolServer output. We first try to open it for read/write, and if that
- # fails, we open it read-only.
-
- addmenu ToolServer 'Open Output' 'begin; open -n "{ToolServerWindow}" || open -r "{ToolServerWindow}"; end ∑∑ "dev:null"'
- addmenu ToolServer '(-' ''
-
- # Quit ToolServer sends a quit message to the ToolServer.
-
- addmenu ToolServer 'Quit ToolServer' 'rshell -q {WhichToolServer}'
-
-
- # Build Menu Additions
- #
- # This is a simple addition to the build menu to run the build in the background.
- #
- AddMenu Build '(-' ''
- AddMenu Build 'Background Build…' ∂
- 'Begin; ∂
- Set NewProgram "`Request "Program Name?" -d "{Program}" || Echo '""'`"; ∂
- Exit If "{NewProgram}" == ""; ∂
- Set Program "{NewProgram}"; ∂
- rshell "begin; directory `directory`; Echo; Echo; BuildProgram ∂"{Program}∂"; end;" {WhichToolServer}{ToolServerRedirection};∂
- End >> "{Worksheet}" ≥≥ Dev:StdOut'
-
-
- # I would suggest creating a script that contains aliases, and variable
- # settings that you use frequently as well as setting the initial state of
- # MPW Shell and ToolServer and then executing that script from both your
- # UserStartup•≈ file and UserStartupTS•≈ file, so that commands, scripts and
- # aliases will work consistently in both environments. You may also use
- # the Set Environment menu item as well.
-
-
- # Finally here is the ToolServerExecute command itself.
-
- set ToolServerStarted 0
-
- alias 'ToolServerExecute' ∂
- 'if "{Active}" != "{ToolServerWindow}"; open -n -t "{ToolServerWindow}"; end; ∂
- if `count -c "{Active}".§` == 0; ∂
- find !0 "{Active}"; ∂
- rshell < "{Active}".§ {WhichToolServer} {ToolServerRedirection}; ∂
- replace §Δ ∂n "{Active}"; ∂
- else; ∂
- rshell < "{Active}".§ {WhichToolServer} {ToolServerRedirection}; ∂
- end; ∂
- set ToolServerStarted 1'
-
-
- #
- # Here is an enhancement (contributed by Warren Harris) that sets
- # ToolServer's default directory to the same thing as MPW Shell's before
- # executing the selected command. You might want to bind this alias to
- # a key instead of ToolServerExecute.
- #
- alias 'ToolServerExecute•dir' ∂
- 'set dir `directory`; ∂
- rshell "directory ∂"{dir}∂"" {WhichToolServer} ∑ dev:null; ∂
- ToolServerExecute'
-